//加载express模块
const express = require('express');
//创建web服务器
const app = express();

//加载cors跨域中间件
const cors = require('cors')
//注册cors
app.use(cors())
app.use(express.urlencoded({
  extended: true
}));
app.use(express.json());

//静态访问
app.use(express.static(__dirname));

//导入模块
const userInfoRouter = require('./router/userRouter')
const addressRouter = require('./router/addressRouter')
const adminRouter = require('./router/adminRouter')
const orderRouter = require('./router/orderRouter')



//注册路由
app.use(addressRouter)
app.use(userInfoRouter)
app.use(adminRouter)
app.use(orderRouter)


//监听5000端口，即web服务器运行在5000端口
app.listen(5000, () => {
  console.log('server running at 5000')
})